package net.butov.wrappers;

/**
 * @author Maxim Butov
 * @version $Id: WrapperFactory.java,v 1.4 2007/11/15 16:35:53 BELHARD\ButovMA Exp $
 */
public class WrapperFactory {

    public static <W> EnhancerObjectFactory<W> createFactory(Class<W> wrapperClass, WrapperMode mode) {
        return createFactory(null, wrapperClass, mode);
    }

    public static <S, W> EnhancerObjectFactory<W> createFactory(S source, Class<W> wrapperClass, WrapperMode mode) {
        WrapperMethodInterceptor interceptor = new WrapperMethodInterceptor(source, wrapperClass, mode);
        return EnhancerObjectFactory.getInstance(wrapperClass, source != null ? source.getClass() : null, interceptor);
    }

    public static <W> W createInstance(Class<W> wrapperClass, WrapperMode mode) {
        return createInstance(null, wrapperClass, mode);
    }

    public static <S, W> W createInstance(S source, Class<W> wrapperClass, WrapperMode mode) {
        return createFactory(source, wrapperClass, mode).newInstance();
    }

    private WrapperFactory() {
    }
}
